/*
 * acm1201.c
 *
 *  Created on: 20 Mar 2010
 *      Author: xuxu
 */
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main()
{
	int i, j;
	int data[51], inver[51];
	int n, count;
	char type;
	while (scanf("%d%*c", &n) && n)
	{
		scanf("%c", &type);
		for (i = 0; i < n; i++)
		{
			scanf("%d", &data[i]);
		}
		if ('P' == type)
		{
			for (i = 0; i < n; i++)
			{
				count = 0;
				for (j = 0; j < i; j++)
				{
					if (data[i] < data[j])
						count++;
				}
				inver[data[i] - 1] = count;
			}
			for (i = 0; i < n - 1; i++)
				printf("%d ", inver[i]);
			printf("%d\n", inver[n - 1]);
		}
		else
		{
			memset(inver, 0, sizeof(inver));
			for (i = 1; i <= n; i++)
			{
				j = 0;
				count=0;
				while (count != data[i - 1])
				{
					if (0 == inver[j])
						count++;
					j++;
				}
				while(inver[j]!=0)
					j++;
				inver[j] = i;
			}
			for (i = 0; i < n - 1; i++)
				printf("%d ", inver[i]);
			printf("%d\n", inver[n - 1]);
		}
	}
	return 0;
}
